//
//  UIFormWebView.m
//  storeapp
//
//  Created by huangyi on 13-5-20.
//  Copyright (c) 2013年 ios. All rights reserved.
//

#import "UIFormWebView.h"

@interface UIFormWebView () <UIWebViewDelegate>

@end

@implementation UIFormWebView

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
    self.navigationItem.leftBarButtonItem=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onButtonClick:)];
    UIWebView *web=[[UIWebView alloc] initWithFrame:self.view.bounds];
    web.autoresizingMask=UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
    web.scalesPageToFit=YES;
    [self.view addSubview:web];
    web.delegate=self;
    [web loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:self.urlString]]];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)show{
    if (self.delegate!=nil) {
        UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:self];
        nav.modalPresentationStyle=UIModalPresentationFormSheet;
        [self.delegate presentViewController:self.navigationController animated:YES completion:nil];
    }
}
-(void)onButtonClick:(id)sender{
    if (sender==self.navigationItem.leftBarButtonItem) {
        [self.navigationController dismissViewControllerAnimated:YES completion:nil];
    }
}

@end
